package com.qingluan.dd.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;

public class LongSocket {
	public boolean isStart =  false;
	private Socket clientSocket ;
	private  int port ;
	private SocketAddress localAddr ;
	private boolean isRunable = false;
	public LongSocket(int port ){
		this.port  = port;
		try {
			clientSocket = new Socket();
			this.localAddr = new InetSocketAddress("", 8080);
			clientSocket.bind(localAddr);
			
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
	
	public void BuildLongConnect() throws IOException{
		this.isStart = true;
		clientSocket.connect(localAddr);
		while (! clientSocket.isConnected()){
			clientSocket.connect(this.localAddr);
		}
		if (clientSocket.isConnected()){
			isRunable = true;
		}
	}
	
	
	public void connect() throws IOException{
		if(isStart){
			BufferedReader br = new BufferedReader(
					new InputStreamReader( 
							clientSocket.getInputStream()
					)
			);
			
			
		}
		
	}
}
